<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Clojure documentation  browser</title><style>
.library
{
  padding: 0.5em 0 0 0 
}
.all-libs-toggle,.library-contents-toggle
{
 font-size: small;
}
.all-libs-toggle a,.library-contents-toggle a
{
 color: white
}
.library-member-doc-whitespace
{
 white-space: pre
}
.library-member-source-toggle
{
  font-size: small;
  margin-top: 0.5em
}
.library-member-source
{
  display: none;
  border-left: solid lightblue 
}
.library-member-docs
{
  font-family:monospace
}
.library-member-arglists
{
  font-family: monospace
}
.library-member-type
{
  font-weight: bold; 
  font-size: small;
  font-style: italic;
  color: darkred
}
.lib-links
{
  margin: 0 0 1em 0
}

.lib-link-header
{
  color: white;
  background: darkgreen;
  width: 100%
}

.library-name 
{ 
  color: white;
  background: darkblue;
  width: 100%
}

.missing-library
{
  color: darkred; 
  margin: 0 0 1em 0 
}

.library-members
{
  list-style: none
}

.library-member-name
{
  font-weight: bold;
  font-size: 105%
}</style><script language="JavaScript" type="text/javascript"> // <![CDATA[

function getElem(id)
{
  if( document.getElementById )
  {
    return document.getElementById( id )
  }
  else if ( document.all )
  {
    return eval( 'document.all.' + id )
  }
  else
    return false;
}

function setDisplayStyle(id,displayStyle)
{
  var elem = getElem (id)
  if (elem)
  {
    elem.style.display = displayStyle
  }

}

function setLinkToggleText (id, text)
{
 var elem = getElem (id)
 if (elem)
 {
   elem.innerHTML = text
 }
}

function collapse(id)
{
  setDisplayStyle (id, 'none')
}

function expand (id)
{
  setDisplayStyle (id, 'block')
}

function toggleSource( id )
{
  toggle(id, 'linkto-' + id, 'Hide Source', 'Show Source')
}

function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
{
  var elem = getElem (targetid)
  var link = getElem (linkid)

  if (elem && link)
  {
    var isOpen = false
    if (elem.style.display == '')
    {
      isOpen = link.innerHTML == textWhenOpen
    }
    else if( elem.style.display == 'block' )
    {
      isOpen = true
    }
    
    if (isOpen)
    {
      elem.style.display = 'none'
      link.innerHTML = textWhenClosed
    }
    else
    {
      elem.style.display = 'block'
      link.innerHTML = textWhenOpen
    }
  }
}

      //]]>
</script><script language="JavaScript" type="text/javascript">// <![CDATA[!
function expandAllNamespaces()
{
expand(&apos;library-contents-readerManager&apos;);
setLinkToggleText(&apos;library-contents-toggle-readerManager&apos;, &apos;-&apos;);

}function collapseAllNamespaces()
{
collapse(&apos;library-contents-readerManager&apos;);
setLinkToggleText(&apos;library-contents-toggle-readerManager&apos;, &apos;+&apos;);

}
// ]]></script></head><body><div class="lib-links"><div class="lib-link-header">Namespaces<span class="all-libs-toggle"> [ <a href="javascript:expandAllNamespaces()">Expand All</a> ] [ <a href="javascript:collapseAllNamespaces()">Collapse All</a> ]</span></div><a class="lib-link" href="#library-readerManager">readerManager</a></div><div class="library"><a name="library-readerManager"/><div class="library-name"><span class="library-contents-toggle">[ <a id="library-contents-toggle-readerManager" href="javascript:toggle(&apos;library-contents-readerManager&apos;, &apos;library-contents-toggle-readerManager&apos;, &apos;-&apos;, &apos;+&apos;)">-</a> ] </span>readerManager</div><div class="library-contents" id="library-contents-readerManager"><div class="library-member-links"><a class="lib-member-link" href="#member-readerManager-erase">erase</a> <a class="lib-member-link" href="#member-readerManager-get-db-vector">get-db-vector</a> <a class="lib-member-link" href="#member-readerManager-get-fields">get-fields</a> <a class="lib-member-link" href="#member-readerManager-get-headers">get-headers</a> <a class="lib-member-link" href="#member-readerManager-get-numFields">get-numFields</a> <a class="lib-member-link" href="#member-readerManager-get-records">get-records</a> <a class="lib-member-link" href="#member-readerManager-new-row">new-row</a> <a class="lib-member-link" href="#member-readerManager-new-values">new-values</a></div><ol class="library-members"><li class="library-member"><a name="member-readerManager-erase"/><dl class="library-member-table"><dt class="library-member-name">erase</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file rowNumber])</span></div><div class="library-member-docs"><div class="library-member-doc-line">erases a row in a file by changing the :deleted flag</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-erase&apos;)" id="linkto-membersource-readerManager-erase">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-erase"><pre>(defn erase
  &quot;erases a row in a file by changing the :deleted flag&quot;
    [file rowNumber]
    (with-open [fileMan (RandomAccessFile. file &quot;rw&quot;)]
        (.readInt fileMan); read magic number
        (let [offset (.readInt fileMan)]
            (.seek fileMan (+ offset (* 161 rowNumber)))
            (.writeShort fileMan 0x8000)))
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-readerManager-get-db-vector"/><dl class="library-member-table"><dt class="library-member-name">get-db-vector</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file])</span></div><div class="library-member-docs"/><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-get-db-vector&apos;)" id="linkto-membersource-readerManager-get-db-vector">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-get-db-vector"><pre>(defn get-db-vector [file]
  &quot;Returns a vector containing magic-number, offset ,num-fields ,fields-meta and records&quot;
  (read-bin-file file)
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-readerManager-get-fields"/><dl class="library-member-table"><dt class="library-member-name">get-fields</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file])</span></div><div class="library-member-docs"/><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-get-fields&apos;)" id="linkto-membersource-readerManager-get-fields">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-get-fields"><pre>(defn get-fields [file]
  &quot;Returns the value of the fields in a file&quot;
  (get file :fields)
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-readerManager-get-headers"/><dl class="library-member-table"><dt class="library-member-name">get-headers</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file])</span></div><div class="library-member-docs"/><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-get-headers&apos;)" id="linkto-membersource-readerManager-get-headers">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-get-headers"><pre>(defn get-headers [file]
  &quot;Returns the header&apos;s fields in the file database to use in a table&quot;    
  ;(keys (first (get-records file)))
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-readerManager-get-numFields"/><dl class="library-member-table"><dt class="library-member-name">get-numFields</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file])</span></div><div class="library-member-docs"/><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-get-numFields&apos;)" id="linkto-membersource-readerManager-get-numFields">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-get-numFields"><pre>(defn get-numFields [file]
  &quot;Return the number of fields in a file&quot;
  (count ( read-bin-rec file))
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-readerManager-get-records"/><dl class="library-member-table"><dt class="library-member-name">get-records</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file])</span></div><div class="library-member-docs"/><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-get-records&apos;)" id="linkto-membersource-readerManager-get-records">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-get-records"><pre>(defn get-records [file]
  &quot;Return the fields in a file db&quot;
  (read-bin-rec file)
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-readerManager-new-row"/><dl class="library-member-table"><dt class="library-member-name">new-row</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file nRecords])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Writes a new row to the file file at the position nRecords</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-new-row&apos;)" id="linkto-membersource-readerManager-new-row">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-new-row"><pre>(defn new-row
&quot;Writes a new row to the file file at the position nRecords&quot;
[file nRecords]
  (let [
     readed    (File. file)
     fileWR    (RandomAccessFile. readed &quot;rw&quot;)
     writeB    (ByteBuffer/allocate 161)
     magicC    (.readInt fileWR)
     channel   (.getChannel fileWR)
     offset    (.readInt fileWR)
       ]
   (.position channel (+ offset (+ 161 nRecords)))
   (.write channel writeB)
   (.close channel)
   (.close fileWR)   
  )
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-readerManager-new-values"/><dl class="library-member-table"><dt class="library-member-name">new-values</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([file row name city size smoking price date owner])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Creates a new register in the file with the specified values</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-readerManager-new-values&apos;)" id="linkto-membersource-readerManager-new-values">Show Source</a> ]</div><div class="library-member-source" id="membersource-readerManager-new-values"><pre>(defn new-values
&quot;Creates a new register in the file with the specified values&quot;
[file row name city size smoking price date owner]
  (let [
        nameB    (ByteBuffer/allocate 64)
        cityB    (ByteBuffer/allocate 64)
        sizeB    (ByteBuffer/allocate 4)
        smokingB (ByteBuffer/allocate 1)
        priceB   (ByteBuffer/allocate 8)
        dateB    (ByteBuffer/allocate 10)
        ownerB   (ByteBuffer/allocate 8)        
       ]
        (.put nameB    (.getBytes name &quot;US-ASCII&quot;))
        (.put cityB    (.getBytes city &quot;US-ASCII&quot;))
        (.put sizeB    (.getBytes size &quot;US-ASCII&quot;))
        (.put smokingB (.getBytes smoking &quot;US-ASCII&quot;))
        (.put priceB   (.getBytes price &quot;US-ASCII&quot;))
        (.put dateB   (.getBytes date &quot;US-ASCII&quot;))
        (.put ownerB   (.getBytes owner &quot;US-ASCII&quot;))

        (with-open [fileWR (RandomAccessFile. file &quot;rw&quot;)]
          (.readInt fileWR); read magic number
          (let [offset (.readInt fileWR)]
          (.seek fileWR (+ offset (* 161 row)))
            (.writeShort fileWR 0)
            (.write fileWR (.array nameB))
            (.write fileWR (.array cityB))
            (.write fileWR (.array sizeB))
            (.write fileWR (.array smokingB))
            (.write fileWR (.array priceB))
            (.write fileWR (.array dateB))
            (.write fileWR (.array ownerB))
          )

   )
 )
)</pre></div></div></dd></dl></li></ol></div></div></body></html>